package com.lenovo.lcdm.common.exception;

import com.lenovo.lcdm.common.enums.BusinessMsgEnum;

/**
 * business exception
 *
 * @author
 */
@SuppressWarnings("squid:S1948")
public class BusinessException extends RuntimeException {
    private int code;
    private Object data;

    public BusinessException() {
        super();
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, int code) {
        super(message);
        this.code = code;
    }

    public BusinessException(BusinessMsgEnum responseMsgEnum) {
        super(responseMsgEnum.getMessage());
        this.code = responseMsgEnum.getCode();
    }

    public BusinessException(String message, int code, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public BusinessException(String message, int code, Object data, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.data = data;
    }

    public BusinessException(BusinessMsgEnum errorCode, Object... args) {
        this(errorCode.formatMsg(args), errorCode.getCode());
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
